package com.shine.common.web.model;

import com.shine.common.Constants;


public class SystemContext {
	
	private static ThreadLocal<Integer> currentPage = new ThreadLocal<Integer>() ;		//分页的起始页
	
	private static ThreadLocal<Integer> pageNumber = new ThreadLocal<Integer>() ;		//分页的大小
	
	private static ThreadLocal<String> sort = new ThreadLocal<String>() ;				//列表的排序字段
	
	private static ThreadLocal<String> order = new ThreadLocal<String>() ;				//列表的排序方式
	
	private static ThreadLocal<Integer> draw = new ThreadLocal<Integer>() ;				//DataTables特有属性
	
	public static void setDraw(Integer _draw) {
		draw.set(_draw) ;
	}
	public static Integer getDraw() {
		return draw.get();
	}
	
	public static Integer getCurrentPage() {
		if(null == currentPage.get()) {
			currentPage.set(0) ;
		} 
		return currentPage.get();
	}

	public static void setCurrentPage(Integer _currentPage) {
		currentPage.set(_currentPage) ;
	}

	public static Integer getPageNumber() {
		if(null == pageNumber.get()) {
			pageNumber.set(Constants.PAGE_NUMBER) ;
		} 
		return pageNumber.get();
	}

	public static void setPageNumber(Integer _pageNumber) {
		pageNumber.set(_pageNumber) ;
	}
	
	

	public static void removeCurrentPage(){
		currentPage.remove();
	}
	public static void removePageNumber(){
		pageNumber.remove();
	}
	public static void removeDraw(){
		draw.remove();
	}
	
	public static String getSort() {
		return sort.get();
	}

	public static void setSort(String _sort) {
		sort.set(_sort) ;
	}

	public static String getOrder() {
		return order.get();
	}

	public static void setOrder(String _order) {
		order.set(_order) ;
	}
	
	public static void removeSort() {
		sort.remove() ; 
	}
	
	public static void removeOrder() {
		order.remove() ; 
	}
	
}
